<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>21.8.动画函数封-节流阀</title>
</head>

<body>
    <script>
        // 声明flag为真
        var flag = true;
        next.addEventListener('click', function () {
            if (flag) {
                // 关闭节流阀
                flag = false;
                if (num == ul.children.length - 1) {
                    ul.style.left = 0;
                    num = 0;
                }
                num++;
                // 回调函数中打开
                animate(ul, -num * focusWidth, function () {
                    // 打开节流阀
                    flag = true;
                })
            }
        })
    </script>
</body>

</html>